<?php 
session_start();
?>

<html>
<head>
	<title>Nachrichten</title>
	<link rel="stylesheet" type="text/css" href="styleMessages.css"/>
</head>
<body>
	<?php
		include("funktionenMessages.php"); //Datei funktionen.php einbinden, diese Datei beinhaltet alle ausgelagerten Funktionen
	   
        if( isset($_POST['id']) ){       
            loesche($_POST['id']); 
        }
		
		if( isset($_GET['logout']) ){        
			session_destroy(); 
        }
		
		if( isset($_SESSION['login']) ){			
				
			if(isset($_SESSION['login']) && ($_SESSION['login'] == 1)){
			
				echo "<a class=\"backLink\" href='../login.php'>Zur&uuml;ck</a>";
			
				?>
				
				<form action="../login.php" method="post">
					<input type="hidden" name="logout">
					<input type="submit" id="logoutButton" class="button" value="Logout">
				</form>
				
				
				<div style='color: #dfdfdf; background-color: rgba(0,0,0,0.6); padding: 10px; margin-bottom: 20px;'>
				<div style='float: right; margin-top: auto 5px;'>
					<form action='messages.php' method='post' onsubmit="return confirm('Wirklich alle L&ouml;schen?');">
						<input type='hidden' name='id' value='0'>
						<input type='submit' value='Delete all'>
					</form>
				</div>
				<h1 style="margin: 0;">Nachrichten</h1></div>
				 
				<?php
					
				gebe_nachrichten_aus();
		  
			}
		
		
		}
		else{ 
				echo "<a class=\"backLink\" href='../login.php'>ADMIN</a>";
		}
		
		
	?>
</body>   
</html>
